#include <vector>
using namespace std;
int findDuplicate(vector<int> &nums) {
  // bitmap
  int bitMapCap = 100000 / 8;
  vector<int> bitMap(bitMapCap, 0);
  for (int i : nums) {
    // 块索引
    int blockIdx = (i - 1) / 8;
    // 块内索引
    int inBlockIdx = (i - 1) % 8;
    int mask = 1 << inBlockIdx;
    if ((bitMap[blockIdx] & mask) == 0) {
      bitMap[blockIdx] = bitMap[blockIdx] | mask;
    } else {
      return i;
    }
  }
  return 0;
}